package y23.May;

import java.util.Arrays;

public class FindMajority {
    public static void main(String[] args) {
        int[] arr = {1, 2, 1, 2, 1, 2, 2};
        int num = 0;
        Arrays.sort(arr);
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] == arr[i - 1]) {
                num++;
            } else if (arr[i] != arr[i - 1]) {
                num = 1;
            }
            if (num > arr.length / 2) {
                System.out.print(arr[i]);
            }
        }
    }
}
